package com.hzjh.h5mall.ui.forgot

import android.graphics.Paint
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.hzjh.base.ext.frame.JHBaseActivity
import com.hzjh.base.ext.route.RouteUrl
import com.hzjh.base.utils.other.ActivityStackManage
import com.hzjh.base.utils.other.KeyboardUtils
import com.hzjh.h5mall.databinding.ActivityForgotStep3Binding
import com.hzjh.h5mall.model.forgot.ForgotVM
import com.hzjh.h5mall.ui.login.LoginActivity

@Route(path = RouteUrl.FORGOT_STEP3_ACTIVITY)
class ForgotStep3Activity : JHBaseActivity<ActivityForgotStep3Binding,ForgotVM>() {
    @JvmField
    @Autowired(name = RouteUrl.PARAMS_EMAIL)
    var email = ""

    @JvmField
    @Autowired(name = RouteUrl.PARAMS_CAPTCHA)
    var captcha = ""

    override fun initData() {

    }

    override fun initView() {
        viewBinding.btnConfirm.apply {
            paint.flags = Paint.UNDERLINE_TEXT_FLAG; //下划线
            paint.isAntiAlias = true;//抗锯齿
            setOnClickListener {
                //修改密码
                KeyboardUtils.hideSoftkeyboard(this@ForgotStep3Activity)
                val password = viewBinding.inputPassword.text.toString()
                viewModel.reqResetPassword(email,captcha,password)
            }
        }
        viewBinding.tvResend.apply {
            paint.flags = Paint.UNDERLINE_TEXT_FLAG; //下划线
            paint.isAntiAlias = true;//抗锯齿
            setOnClickListener {
                ActivityStackManage.toActivity(LoginActivity::class.java)
            }
        }
        viewBinding.inputPassword.setTextChangeListener {
            viewBinding.btnConfirm.isEnabled=!it.isNullOrBlank()
        }
    }

    override fun initViewBinding(): ActivityForgotStep3Binding {
        return ActivityForgotStep3Binding.inflate(layoutInflater)
    }
}